// 题目链接：https://www.acwing.com/file_system/file/content/whole/index/content/3559/

// 1.动态规划 + 三维数组
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;

const int N = 1005;
const int L = 105;
int v[N], m[N], w[N];
int n, V, M;

int f[N][L][L];

int main()
{
    scanf("%d %d %d", &n, &V, &M);
    for (int i = 1; i <= n; ++i)
    {
        scanf("%d %d %d", &v[i], &m[i], &w[i]);
    }

    for (int i = n; i >= 1; --i)
    {
        for (int j = 0; j <= V; ++j)
        {
            for (int k = 0; k <= M; ++k)
            {
                if (j < v[i] || k < m[i])
                    f[i][j][k] = f[i + 1][j][k];
                else
                    f[i][j][k] = max(f[i + 1][j][k], f[i + 1][j - v[i]][k - m[i]] + w[i]);
            }
        }
    }

    printf("%d\n", f[1][V][M]);

    return 0;
}

//--------------------------------------------------------------------------------------------------
// 2.动态规划 + 二维滚动数组
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;

const int N = 1005;
const int L = 105;

int v[N], m[N], w[N];
int n, V, M;

int f[L][L];

int main()
{
    scanf("%d %d %d", &n, &V, &M);
    for (int i = 1; i <= n; ++i)
    {
        scanf("%d %d %d", &v[i], &m[i], &w[i]);
    }

    for (int i = n; i >= 1; --i)
    {
        for (int j = V; j >= v[i]; --j)
        {
            for (int k = M; k >= m[i]; --k)
            {
                f[j][k] = max(f[j][k], f[j - v[i]][k - m[i]] + w[i]);
            }
        }
    }

    printf("%d\n", f[V][M]);

    return 0;
}